home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15654 < prev    next >
Encoding:
Text File  |  1996-08-05  |  877 b   |  33 lines

  1. Path: grimsel.zurich.ibm.com!usenet
  2. From: wgk@zurich.ibm.com (Keith Whittingham)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Small question
  5. Date: 7 Apr 1996 12:37:03 GMT
  6. Organization: IBM Research, ZRH
  7. Message-ID: <4k8ctf$oca@grimsel.zurich.ibm.com>
  8. References: <31674eeb.132847918@vixa.voyager.net>
  9. Reply-To: wgk@zurich.ibm.com
  10. NNTP-Posting-Host: pine.zurich.ibm.com
  11. X-Newsreader: IBM NewsReader/2 v1.00
  12.  
  13. In <31674eeb.132847918@vixa.voyager.net>, sence@ava.taby.se (Bjorn Osterman) writes:
  14. >If I have 2 cpp files and i use the same global variable that i define
  15. >in some file that both cpp-files includes. How do I tell the compiler
  16. >that the variable is the same and that it shouldn't make space 2
  17. >times?
  18. >
  19.  
  20. define it in one file as non-static e.g:
  21.  
  22.   int GobalInt;
  23.  
  24. and in all others as extern
  25.  
  26.   extern int Global;
  27.  
  28. That tells the compiler that it's defined elsewhere
  29.  
  30. Keith
  31.  
  32.  
  33.